package com.example.playerinfogame

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Spinner
import androidx.appcompat.app.AppCompatActivity

class EditInfoActivity : AppCompatActivity() {

    private lateinit var etName: EditText
    private lateinit var spinnerGender: Spinner
    private lateinit var etPhone: EditText
    private lateinit var btnSave: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_edit_info)

        etName = findViewById(R.id.etName)
        spinnerGender = findViewById(R.id.spinnerGender)
        etPhone = findViewById(R.id.etPhone)
        btnSave = findViewById(R.id.btnSave)

        // 默认值
        etName.setText("张三")
        etPhone.setText("1234567890")

        btnSave.setOnClickListener {
            val name = etName.text.toString()
            val gender = spinnerGender.selectedItem.toString()
            val phone = etPhone.text.toString()

            // 回传数据（仅用于演示，不保存）
            val resultIntent = Intent()
            resultIntent.putExtra("name", name)
            resultIntent.putExtra("gender", gender)
            resultIntent.putExtra("phone", phone)
            setResult(RESULT_OK, resultIntent)
            finish()
        }
    }
}